#pragma once

#ifndef SAFE_DELETE_H
#define SAFE_DELETE_H

#define SAFE_FREE(p) { free(p); p = NULL; }
#define SAFE_DELETE(p) { delete p;p = NULL; }
#define SAFE_DELETE_ARRAY(p) { delete[] p; p = NULL; }

template< class T > void SafeDelete( T*& pVal )
{
    delete pVal;
    pVal = NULL;
}

template< class T > void SafeDeleteArray( T*& pVal )
{
    delete[] pVal;
    pVal = NULL;
}

#endif